package controller.api;
import java.util.List;

import com.jfinal.aop.Before;
import com.jfinal.aop.Inject;
import com.jfinal.kit.Kv;
import com.jfinal.kit.Ret;

import common.inter.ServicerStationInter;
import common.inter.StaffStationInter;
import model.ReagentRenewal;
import service.ReagentRenewalService;

public class ApiReagentRenewalController extends BaseApiController {
	@Inject ReagentRenewalService reagentRenewalService ;

	@Before(ServicerStationInter.class)
	public void list() {
	    Kv kv = getParamKv() ;
	    kv.set("trr.stationId", getStation().getId());
	    Integer pageNumber = getParaToInt("pageNumber", 1);
	    Integer pageSize = getParaToInt("pageSize", 10);
	    set("page", reagentRenewalService.getApiPage( kv , pageNumber, pageSize));
	    renderJson();
	}
	
	@Before(StaffStationInter.class)
	public void save() {
		List<ReagentRenewal> list = getModelList(ReagentRenewal.class);
		String instrumentName = getPara("instrumentName");
        Ret ret = reagentRenewalService.save(list , instrumentName , getStaff() , getStation() );
        renderJson(ret);
	}
}
